﻿using Infrastructure;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain.AUTH;
using OpenAuth.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpenAuth.App.AUTH
{
    public class Auth_Org_InfoApp : BaseApp<Auth_Org_Info, OpenAuthDBContext>
    {
        private DbExtension _dbExtension;
        /// <summary>
        /// 加载全部组织机构
        /// </summary>
        /// <returns></returns>
        public List<Auth_Org_Info> load(Auth_Org_InfoListReq request) {
            var loginContext = _auth.GetCurrentUser();
            if (loginContext == null)
            {
                throw new CommonException("登录已过期", Define.INVALID_TOKEN);
            }
            var obj= UnitWork.Find<Auth_Org_Info>(null).ToList();
            if (!string.IsNullOrEmpty(request.key)) {
                obj = obj.Where(u => u.PARENT_ID.Contains(request.key)).ToList();
            }
            return obj;
        }
        public Auth_Org_InfoApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<Auth_Org_Info, OpenAuthDBContext> repository, IAuth auth,
            RevelanceManagerApp revelanceApp,DbExtension dbExtension) : base(unitWork, repository, auth) {
            _dbExtension = dbExtension;
        }
     }
}
